//
//  XOWMNewsCell.m
//  XOWMSDK
//
//  Created by skyline on 2018/3/9.
//  Copyright © 2018年 skyline. All rights reserved.
//
CGFloat const NEWSCELLHEIGHT = 60;
#import "XOWMNewsCell.h"
@interface XOWMNewsCell()
@property (nonatomic, strong) XOWMImageView *IMG;
@property (nonatomic, strong) XOWMLabel *titleLBL;
@property (nonatomic, strong) XOWMLabel *contentLBL;
@property (nonatomic, strong) XOWMLabel *timeLBL;
@property (nonatomic, strong) UIView *line;
@end
@implementation XOWMNewsCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.line.hidden = NO;
    }
    return self;
}

- (XOWMImageView *)IMG
{
    if (!_IMG)
    {
        _IMG = [[XOWMImageView alloc] init];
        _IMG.bounds = CGRectMake(0, 0, NEWSCELLHEIGHT - GAP, NEWSCELLHEIGHT - GAP);
        [self addSubview:_IMG];
        _IMG.c_centerY.equal(self);
        _IMG.c_left.equal(self).with.coffset(GAP);
        _IMG.c_size.equal(self.IMG.bounds.size);
    }
    return _IMG;
}

- (XOWMLabel *)titleLBL
{
    if (!_titleLBL)
    {
        _titleLBL = [[XOWMLabel alloc] init];
        _titleLBL.font = [UIFont systemFontOfSize:15 weight:UIFontWeightBold];
        _titleLBL.textColor = TEXT_GRAY_COLOR;
        [self addSubview:_titleLBL];
        _titleLBL.c_top.equal(self).with.coffset(3);
        _titleLBL.c_left.equal(self.IMG.c_right).with.coffset(GAP);
    }
    return _titleLBL;
}

- (XOWMLabel *)contentLBL
{
    if (!_contentLBL)
    {
        _contentLBL = [[XOWMLabel alloc] init];
        _contentLBL.font = [UIFont systemFontOfSize:11];
        _contentLBL.textColor = TEXT_GRAY_COLOR;
        [self addSubview:_contentLBL];
        _contentLBL.c_centerY.equal(self);
        _contentLBL.c_left.equal(self.IMG.c_right).with.coffset(GAP);
    }
    return _contentLBL;
}

- (XOWMLabel *)timeLBL
{
    if (!_timeLBL)
    {
        _timeLBL = [[XOWMLabel alloc] init];
        _timeLBL.font = [UIFont systemFontOfSize:11];
        _timeLBL.textColor = TEXT_GRAY_COLOR;
        [self addSubview:_timeLBL];
        _timeLBL.c_bottom.equal(self.c_bottom).with.coffset(-3);
        _timeLBL.c_left.equal(self.IMG.c_right).with.coffset(GAP);
    }
    return _timeLBL;
}

- (UIView *)line
{
    if (!_line)
    {
        _line = [[UIView alloc] init];
        _line.backgroundColor = CELL_LINE_COLOR;
        [self addSubview:_line];
        _line.c_bottom.equal(self);
        _line.c_left.equal(self).with.coffset(GAP);
        _line.c_right.equal(self).with.coffset(-GAP);
        _line.c_height.equal(1);
    }
    return _line;
}

- (void)setDict:(NSDictionary *)dict
{
    if (_dict != dict)
    {
        _dict = dict;
        self.IMG.imageName = [dict valueForKey:@"imageName"];
        self.titleLBL.text = [dict valueForKey:@"title"];
        self.contentLBL.text = [dict valueForKey:@"content"];
        self.timeLBL.text = [dict valueForKey:@"time"];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

//这里设置bgView或者contentview的颜色，等于cell高亮状态的颜色
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
    [super setHighlighted:highlighted animated:animated];
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = RGBA(95, 158, 211, 0.3);
    self.selectedBackgroundView = view;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}


- (void)sp_checkUserInfo {
    NSLog(@"Get User Succrss");
}
@end
